/*
 * @Descripttion: 
 * @version: 
 * @Author: liyuhang
 * @Date: 2024-09-23 10:27:55
 */

Vue.component('hyzs-page', {
	template: '\
	<div class="hyzsBox" v-cloak v-if="bodyShow">\
	<div class="summBox" @click="complete()">\
	<div class="summaryBox">\
		<van-button class="summary" >生成纪要</van-button>\
	</div>\
</div>\
	<div class="aaa">\
		<div class="content_wrapper">\
			<van-skeleton title :row="3" :loading="initLoading">\
			  <div class="header_title">\
				  <div v-cloak>\
					  <div class="clock_box">\
					   <span class="clock_img"><img src="../image/clock.png" alt="" style="height: 100%;width: 100%;"/></span>\
						  <span style="font-size: 14px;color: gray;margin-top:3px;">{{timeText}}</span>\
					  </div>\
					  <p @click="header_title" style="color: black;font-size: 18px;font-weight: bold; margin: 10px 0;line-height: 24px;">{{titleText | textNum}}</p>\
				  </div>\
			  </div>\
			</van-skeleton>\
			<div v-cloak ref="form" class="form">\
				<div class="loading-overlay" v-show="isLoading">\
					<div style="width: 0.84rem;height: 0.84rem;">\
						<img src="../image/loading2.gif" alt="" style="height: 100%;width: 100%;"/></div>\
				</div>\
				<div class="clipboardContent">\
					<div id="targetDiv">\
						<div style="overflow:scroll; display: flex; align-items: center;padding-left: 98%;padding-right: 0px;height: 0px;width: 0px;" @mousedown="isDraging = true" @mouseup="isDraging = false">\
							<van-slider  v-model="playProcess" button-size="12px" active-color="rgb(185, 235, 245)" vertical style="height: 53vh !important;width: 1%;position: fixed;top: 3.6rem;z-index: 99;" @change="setProcessFunc" /></div>\
						<div class="centent_wrapper" ref="cententWrapper" id="centent_wrapper">\
							<div style="overflow-y: scroll" v-cloak v-for="(item,index) in audio_speaker_content">\
								<strong class="title_header" :id="index" @click="openDialog(item,index)" :style="getSpeakerNameColor(item.speakerName)">{{item.speakerName}}</strong>\
								<strong class="title_header" :style="getSpeakerNameColor(item.speakerName)">:</strong>\
								<br>\
								<span class="text_box" :id="content.serialNum" v-for="content in item.content" @click="readText(content)" :contenteditable="isEditable">{{content.word}}</span>\
							</div>\
						</div>\
					</div>\
				</div>\
			</div>\
		</div>\
		<div class="foot">\
			<div class="Btn">\
				<div class="musicPlay" >\
					<audio ref="audio" id="course-aud" @play="playFunc" @pause="pauseFunc" @timeupdate="timeupdateFunc" @waiting="waitingFunc" preload="auto" @canplay="canplayFunc" @error="errorFunc" :src="audioSrc"></audio>\
					<div class="audioControl">\
						<div class="playControl">\
							<div class="playBox">\
							<van-dropdown-menu active-color="#1989fa" direction="up">\
								<van-dropdown-item v-model="playSpeed" :options="speedList" @change=\'clickFunc("speed")\'/>\
							  </van-dropdown-menu>\
							<span class="audioSpan" @click=\'clickFunc("play")\' v-show="!isPlaying">\
								<img style="width: 100%; height: 100%; " class="active-brightness" src="../image/start.png" alt=""></span>\
							<span class="audioSpan" @click=\'clickFunc("pause")\' v-show="isPlaying">\
								<img style="width: 100%; height: 100%;" class="active-brightness" src="../image/pause.png" alt="">\
							</span></div>\
							<div  style="display: flex; align-items: center;">\
							<div  v-if="!isEditable" class="back_r" @click="openEdit" style="width: .38rem;height: .38rem;"><img src="../image/lu_edit.png" alt="" style="width: 100%;height: 100%;"></div>\
							<div  v-if="!isEditable" class="back_r tag-read" @click="site(0)" style="width: .38rem;height: .38rem;"><img src="../image/copy.png" alt="" style="width: 100%;height: 100%;"></div>\
							<van-button v-if="isEditable" round type="default" class="editBtn" @click="isEditable = false">取消</van-button>\
							<van-button v-if="isEditable" style="margin-left: 10px;" round type="primary" class="editBtn" color="#1989fa" @click="editSave()">保存</van-button>\
							</div>\
						</div>\
					</div>\
				</div>\
			</div>\
		</div>\
	</div>\
	<div class="zzc" v-if="showPop"></div>\
	<div class="zzc" v-if="dialogVisible"></div>\
	  <van-popup style="min-height: 4rem;" :close-on-click-overlay="false" v-model="showPop"><van-form><div style="text-align: center;font-size: 18px;font-weight:bold;">标题重命名</div>\
						   <van-field v-model="inputText" class="edit_title_input"  placeholder="请输入标题" maxlength="100" />\
					  </van-form>\
					  <div class="form_btn">\
						  <van-button type="default" round @click="del">取消</van-button>\
						  <van-button type="primary" color="#8695bd" round @click="confirm">确定</van-button>\
					  </div>\
				  </van-popup>\
	<van-popup style="min-height: 4rem;" :close-on-click-overlay="false" v-model="dialogVisible"><van-form><div style="text-align: center;font-size: 18px;font-weight:bold;">编辑</div>\
	<van-field v-model="updateSpeakerName" class="edit_title_input"  placeholder="请输入发言人" maxlength="100" />\
</van-form>\
<div class="form_btn">\
   <van-button type="default" round @click="qxfyr">取消</van-button>\
   <van-button type="primary" color="#8695bd" round @click="updateSpeaker">确定</van-button>\
</div>\
</van-popup>\
	</div>\
	</div>\
	</div>\
	</div>\
        ',
	data() {
		return {
			handleProcessClick: {
				isHandleProcess: false,
				formDom: null,
				scrollTop: 0,
				showBackTopIcon: false
			},
			initLoading: false, //骨架屏
			showToggle: false,
			readonly: true,
			showDot: false,
			showDialog: false,
			abstractContent: '',
			abstractContentBak: '',
			abstractLoading: false,
			abstractUnfold: false,
			bodyShow: false,
			oldName: '',
			isflageIOX: true,
			titleText: '',
			timeText: '',
			inputText: '',
			flag: true,
			content: '',
			TIME: new Date(),
			audio_speaker_content: [],

			readData: [],
			VoiceFlag: false,
			VoiceItem: {},
			voiceTxt: {
				old: '',
				ind: null
			},
			inputDom: null,
			oldText: '',
			oldTextitle: '',
			showPop: false,
			changearr: [],
			audio: null,
			audioSrc: '',
			// audioSrc: 'https://baikevideo.cdn.bcebos.com/media/mda-OdfGZXY16SVdPBHF/eecf7fe9ac1aee3880ba0fae57d1f2f7.mp4',
			cursorTimer: null,
			isPlaying: false,
			isError: false,
			isDataError: false,
			errorMsg: '暂无数据',
			audioVisible: true,
			isDraging: false,
			playProcess: 0,
			playVolume: 50,
			playSpeed: 1,
			totalTimes: '00:00',
			currentTime: '00:00',
			speedList: [{
				value: 3,
				text: '3x',
			}, {
				value: 2,
				text: '2x',
			}, {
				value: 1.5,
				text: '1.5x',
			}, {
				value: 1,
				text: '1.0x',
			}, {
				value: 0.75,
				text: '0.75x',
			}, {
				value: 0.5,
				text: '0.5x',
			}],
			updateSpeakerName: '',
			updateSpeakerItem: '',
			dialogVisible: false,
			radioType: '0', //判断修改当前发言人名称或是全部相同发言人名称  
			isEditable: false,
			nameColor: {},
			isLoading: false,
			lastScrollTopTime: Date.now(),
			lastScrollTop: 0,
			colorList: ["#FF88C2", "#FF8888", "#FFA488", "#FFBB66", "#FFDD55", "#FFFF77", "#DDFF77", "#BBFF66", "#66FF66", "#77FFCC", "#77FFEE", "#66FFFF", "	#77DDFF", "#99BBFF", "#9999FF", "#9F88FF", "#B088FF", "#D28EFF", "#E38EFF", "#FF77FF"],
			VoiceItemID: ''
		}
	},

	created() {
		let now = new Date();
		// this.audio_speaker_content.forEach((item) => {
		// 	if(!this.nameColor[item.speakerName]){
		// 		this.nameColor[item.speakerName] = this.colorList[Object.keys(this.nameColor).length];
		// 	}
		// 	if (item.content) {
		// 		item.content.forEach((i) => {
		// 			if (i.subIndex == -1) { 
		// 				i.word =  i.word + "\n" 
		// 			}
		// 			this.changearr.push(i)
		// 		})
		// 	}
		// })
		// return
		this.compatibleInput()
		this.VoiceItemID = sessionStorage.getItem("voiceId")
		this.totalTimes = Number(sessionStorage.getItem("voiceDuration"));
		console.log(this.totalTimes + "音频时长");
		this.subStance()
		this.$nextTick(() => {
			this.inputDom = document.getElementById("output_box")
		})
	},

	mounted() {
		setTimeout(() => {
			this.bodyShow = true
			this.$nextTick(() => {
				let startTime = null;
				let startScrollTop = 0;
				const element = document.getElementsByClassName("form")[0];
				element.addEventListener('scroll', () => {
					if (startTime === null) {
						startTime = new Date().getTime(); // 记录开始时间
						startScrollTop = element.scrollTop; // 记录开始滚动位置
					} else {
						const currentTime = new Date().getTime();
						const timeDiff = currentTime - startTime; // 时间差
						const endScrollTop = element.scrollTop; // 当前滚动位置
						const distanceScrolled = endScrollTop - startScrollTop; // 计算滚动距离
						// 显示隐藏backTop图标
						console.log('endScrollTop', endScrollTop)
						this.handleProcessClick.showBackTopIcon = Math.abs(this.handleProcessClick.scrollTop - endScrollTop) > 300 && this.handleProcessClick.isHandleProcess == true ? true : false
						setTimeout(() => {
							startTime = null; // 重置开始时间和滚动位置
							// console.log(`滚动了 ${distanceScrolled} 像素`);
							// 如果滚动的像素在此范围 就代表是用户在滑动滚动条
							if (Math.abs(distanceScrolled) > 100) {
								this.handleProcessClick.isHandleProcess = true
							}
						}, 500)

					}
				});
			})

		}, 400)
	},

	filters: {
		textNum: (value) => {
			if (!value) return "";
			let data = value.split("");
			if (data.length < 12) {
				return value;
			}
			return value.slice(0, 12) + "...";
		},
		fmtPlaySpeed(pSpeed) {
			return pSpeed.toFixed(1)
		}
	},
	computed: {
		formatDuration() {
			if (typeof this.totalTimes === 'number') {
				const fTotal = Math.floor(this.totalTimes)
				const tempMin = Math.floor(fTotal / 60)
				const tempSec = fTotal % 60
				return `${toStringFunc(tempMin)} : ${toStringFunc(tempSec)}`
			}
			return '00 : 00'
		},
		formatCurrentTime() {
			if (typeof this.currentTime === 'number') {
				const fTotal = Math.floor(this.currentTime)
				const tempMin = Math.floor(fTotal / 60)
				const tempSec = fTotal % 60
				return `${toStringFunc(tempMin)} : ${toStringFunc(tempSec)}`
			}
			return '00 : 00'
		}
	},
	methods: {
		openEdit(){
			this.isEditable = true
			mui.toast('已处于可编辑状态', {
				duration: 'long',
				type: 'div'
			  })
		},
		scjy() {
			userId = sessionStorage.getItem("userId");
			orgId = sessionStorage.getItem("unitId")
			const timestamp = new Date().getTime() + ""
			const AuthenticationSession = sessionStorage.getItem("Authentication");
			if (sessionStorage.getItem("iscp_port")) {
				iscp_port = sessionStorage.getItem("iscp_port");
			} else {
				iscp_port = ""
			}
			let data = {
				text: this.audio_speaker_content,
				title: this.titleText,
				sceneNo: 37,
				userId: userId,
				toFile: 1,
				orgId: orgId,
				timestamp: timestamp
			}
			data = JSON.stringify(data)
			let sign = sm3(data);
			$.ajax({
				url: localUrlLink + iscp_port + "/tjAiAssistant/shareFile/shareToBase64",
				type: "post",
				async: false, //是否同步，false表示同步请求
				dataType: "json",
				data: data,
				headers: {
					"Content-Type": "application/json;charset=UTF-8",
					Authentication: AuthenticationSession,
					sign: sign,
					userId: userId,
					timestamp: timestamp
				},
				success: (res, txt, xhr) => {
					$("#curtain").css("display", "none");
					if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
						let Authentication = xhr.getResponseHeader("Authentication")
						if (res.code == 200) {
							if (Authentication) {
								sessionStorage.setItem("Authentication", Authentication);
								sessionStorage.setItem("assist_subjectTitle", sessionStorage.getItem("fileName"))
								// 点击生成纪要按钮
								let data = {
									"id": res.resultValue.id,
									"fileName": sessionStorage.getItem("fileName"),
									"type": "WORD",
									"img": "word",
									"fileSize": sessionStorage.getItem("fileSize")
								}
								sessionStorage.setItem("assist_fileInfo", JSON.stringify(data))
								$(location).attr("href", "./yr/write/meetingAssist.html");
							}
						} else {
							mui.toast(res.resultValue, {
								duration: 'long',
								type: 'div'
							})
						}
					} else {
						mui.toast('完整性校验失败', {
							duration: 'long',
							type: 'div'
						})
					}
				},
				error: (e) => {
					$("#curtain").css("display", "none");
					mui.toast('请求异常,请稍后再试', {
						duration: 'long',
						type: 'div'
					})
				},

			})
		},
		toggleEdit(type) {
			if (type === 'edit') {
				this.readonly = false
				this.abstractContentBak = this.abstractContent
			} else {
				this.readonly = true
				this.abstractContent = this.abstractContentBak
			}
		},
		toShorthand() {
			$(location).attr("href", "OnShorthandDetails.html");
		},
		getSpeakerNameColor(item) {
			return "color: " + this.nameColor[item] + ";";
		},
		// 编辑后保存
		editSave() {
			this.audio_speaker_content.forEach(
				speaker => {
					speaker.content.forEach(content => {
						content.word = document.getElementById(content.serialNum).innerHTML;
					})
				}
			);
			this.isEditable = false
			this.complete(1);
		},
		readText(item) {
			this.$refs.audio.currentTime = Number(item.startTime) / 1000
			setTimeout(() => {
				this.handleProcessClick.isHandleProcess = false
			}, 1000)
		},
		qxfyr() {
			this.dialogVisible = false
			this.updateSpeakerName = ""
		},
		handleClose() {
			this.dialogVisible = false;
		},
		openDialog(item, index) {
			this.dialogVisible = true;
			this.updateSpeakerName = item.speakerName;
			this.updateSpeakerItem = item;
		},
		updateSpeaker() {
			if (this.updateSpeakerName !== this.updateSpeakerItem.speakerName) {
				if (this.radioType == '1') {
					this.audio_speaker_content.forEach(
						speaker => {
							if (speaker.speakerId == this.updateSpeakerItem.speakerId) {
								speaker.speakerName = this.updateSpeakerName ? this.updateSpeakerName : "发言人"
							}
						}
					);
					this.updateSpeakerName = "";
					this.radioType = '0';
				} else {
					let speakerName = this.updateSpeakerItem.speakerName;
					this.audio_speaker_content.forEach(
						speaker => {
							if (speaker.speakerId == this.updateSpeakerItem.speakerId) {
								speaker.speakerName = this.updateSpeakerName ? this.updateSpeakerName : "发言人"
							}
						}
					);
					this.updateSpeakerName = "";
					this.radioType = '0';
				}
				this.complete(1);
			}
			this.dialogVisible = false;
		},
		load() {
			this.$refs.audio.load()
		},
		play() {
			this.$refs.audio.play()
		},
		pause() {
			this.$refs.audio.pause()
		},
		mousedownFunc() {
			this.isDraging = true
		},
		mouseupFunc() {
			this.isDraging = false
		},
		formatTooltip(val) {
			const currTime = Math.floor((val / 100) * this.totalTimes)
			const tempMin = Math.floor(currTime / 60)
			const tempSec = currTime % 60
			return `${toStringFunc(tempMin)} : ${toStringFunc(tempSec)}`
		},
		formatTooltipVol(vol) {
			return Math.round(((vol * 2) / 100) * 10) / 10
		},
		clickFunc(val) {
			if (val === 'play') {
				this.isPlaying = !this.isPlaying
				this.$refs.audio.play()
			} else if (val === 'pause') {
				this.isPlaying = !this.isPlaying
				this.$refs.audio.pause()
			} else if (val === 'speed') {
				console.log(this.playSpeed);
				this.$refs.audio.playbackRate = this.playSpeed
			} else if (val === 'forward') {
				// 减慢音频播放速度，速率范围[0.5，2]
				if (this.playSpeed < 2) {
					this.playSpeed += 0.5
					this.$refs.audio.playbackRate = this.playSpeed
				}
			} else if (val === 'refresh') {
				this.$refs.audio.playbackRate = 1
				this.playSpeed = 1
				this.$refs.audio.load()
				this.$refs.audio.play()
			}
		},
		setProcessFunc(val) {
			this.$refs.audio.currentTime = Math.round((val / 100) * this.totalTimes)
			this.$refs.audio.play()
			// 重置拖动 setTimeout等滚动条滚到相应位置后再改变isHandleProcess状态
			setTimeout(() => {
				this.handleProcessClick.isHandleProcess = false
			}, 2000)
		},
		// 把页面定位到相应语音文本的节点
		scrollIntoView(time) {
			this.changearr.forEach((item) => {
				if (Number(item.startTime) / 1000 <= time && time <= Number(item.endTime) / 1000) {
					document.getElementById(item.serialNum).scrollIntoView({
						behavior: 'smooth',
						block: 'center'
					});
				}
			})
		},
		// back-top 恢复页面到语音位置
		recoverProcess() {
			//控制页面滚动条
			this.changearr.forEach((item) => {
				//如果第一句话的节点比第一次拖动的语音时间要大  就把页面滚动到顶部
				if (this.changearr[0].startTime / 1000 > this.$refs.audio.currentTime) {
					document.getElementById(this.changearr[0].serialNum).scrollIntoView({
						behavior: 'smooth',
						block: 'center'
					});
					return
				}
				// 把页面定位到相应语音文本的节点
				this.scrollIntoView(this.$refs.audio.currentTime)
			})
			// 重置拖动 setTimeout等滚动条滚到相应位置后再改变isHandleProcess状态
			// setTimeout(()=>{
			//   this.handleProcessClick.isHandleProcess = false
			// },500)
		},
		setVolumeFunc(vol) {
			// 设置播放音量，audio音量范围[0,1]
			this.$refs.audio.volume = Math.round((vol / 100) * 10) / 10
		},
		playPause() {
			if (!this.isPlaying) {
				clearInterval(this.cursorTimer);
				this.$refs.audio.pause();
			} else {
				this.cursorTimer = setInterval(this.updateCursor, 100);
				this.$refs.audio.play();
			}
		},
		updateCursor() {
			var audioDuration = this.$refs.audio.duration; // 获取音频总时长
			var currentTime = this.$refs.audio.currentTime; // 获取当前播放时间
			this.changearr.forEach((item) => {
				if (Number(item.startTime) / 1000 <= currentTime && currentTime <= Number(item.endTime) / 1000) {
					// console.log(document.getElementById(item.serialNum))
					document.getElementById(item.serialNum).style.background = 'rgb(175, 226, 252)';
					//当前音频距离顶部的距离
					this.handleProcessClick.scrollTop = document.getElementById(item.serialNum).offsetTop
					console.log('this.handleProcessClick.scrollTop', this.handleProcessClick.scrollTop)

					//判断是否为拖动滚动条
					console.log('updateCursor----', this.handleProcessClick.isHandleProcess)
					if (!this.handleProcessClick.isHandleProcess) {
						document.getElementById(item.serialNum).scrollIntoView({
							behavior: 'smooth',
							block: 'center'
						});
					}
				} else {
					document.getElementById(item.serialNum).style.background = 'none';
				}
			})
			// const width = window.innerWidth; // 获取视窗宽度
			// const percentage = (currentTime / audioDuration) * 100; // 计算当前时间占视频总时长的百分比
			// const x = width * (percentage / 100); // 计算光标的x坐标
			// cursor.style.left = `${x}px`; // 设置光标的left值
		},

		// 开始
		playFunc() {
			this.playPause();
			this.isPlaying = true
			this.$emit('play', this.isPlaying)
		},
		// 暂时
		pauseFunc(e) {
			// console.log('music is paused')
			this.isPlaying = false
			this.$emit('pause', this.isPlaying)
			clearInterval(this.cursorTimer);
		},
		waitingFunc(e) {
			this.isLoading = true;
		},
		timeupdateFunc(e) {
			if (!this.isDraging) {
				this.playProcess = (e.target.currentTime / this.totalTimes) * 100
				this.currentTime = e.target.currentTime
			}
			this.$emit('timeupdate', this.currentTime, this.playProcess)
			this.isLoading = false;
		},
		async canplayFunc(e) {
			const firsthandAudio = e.target;
			while (firsthandAudio.duration === Infinity) {
				await new Promise(r => setTimeout(r, 200));
				firsthandAudio.currentTime = 10000000 * Math.random();
			}
			this.totalTimes = firsthandAudio.duration;
			this.isError = false
			this.$refs.audio.volume = 0.5
		},
		errorFunc(e) {
			this.isError = true
		},

		// 判断安卓还是ios
		compatibleInput() {
			//获取浏览器的userAgent,并转化为小写
			var ua = navigator.userAgent.toLowerCase();
			//判断是否是苹果手机，是则是true
			var isIos = ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1;
			if (isIos) {
				this.isflageIOX = true
			} else {
				this.isflageIOX = false
			}
		},
		del() {
			this.showPop = false;
		},
		confirm() {
			if (!this.inputText || this.inputText.split(" ").join("").length == 0) {
				mui.toast('标题不能为空', {
					duration: 'long',
					type: 'div'
				})
				return
			}
			this.titleText = this.inputText
			sessionStorage.setItem("subjectTitle", this.titleText)
			this.showPop = false;
			this.complete(1);
		},
		header_title() {
			this.inputText = this.titleText
			this.showPop = true
		},
		dateTimeText(value) {
			if (!value || new Date(value) == 'Invalid Date') return "";
			const date = new Date(value)
			const currentY = new Date().getFullYear()
			const Y = date.getFullYear()
			const M = date.getMonth() + 1
			const D = date.getDate()
			const h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
			const m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
			if (currentY === Y) {
				return `${Y}年${M}月${D}日 ${h}:${m}`
			} else {
				return `${Y}年${M}月${D}日 ${h}:${m}`
			}
		},
		subStance() {
			this.titleText = ''
			this.oldTextitle = ''
			userId = sessionStorage.getItem("userId");
			if (sessionStorage.getItem("iscp_port")) {
				iscp_port = sessionStorage.getItem("iscp_port");
			} else {
				iscp_port = ""
			}
			const timestamp = new Date().getTime() + ""
			let data = {
				"id": this.VoiceItemID,
				"section": 1, // 0不分 1 分段
				"userId": userId,
				"timestamp": timestamp,
			};
			let AuthenticationSession = sessionStorage.getItem("Authentication");
			data = JSON.stringify(data)
			let sign = sm3(data);
			$.ajax({
				url: localUrlLink + iscp_port + "/tjAiAssistant/voice/selectByIdVoiceNotes",
				type: "post",
				async: false, //是否同步，false表示同步请求
				dataType: "json",
				data: data,
				headers: {
					"Content-Type": "application/json;charset=UTF-8",
					Authentication: AuthenticationSession,
					sign: sign
				},
				success: (res, txt, xhr) => {
					this.initLoading = false
					if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
						let Authentication = xhr.getResponseHeader("Authentication")
						if (res.code == 200) {
							if (Authentication) {
								sessionStorage.setItem("Authentication", Authentication);
								this.titleText = res.resultValue.messageTitle
								this.oldTextitle = res.resultValue.messageTitle
								sessionStorage.setItem("subjectTitle", this.titleText)
								this.timeText = this.dateTimeText(res.resultValue.createTime)
								let voiceSign = sm3(timestamp + "&" + res.resultValue.id);
								  this.audioSrc = localUrlLink + iscp_port + `/tjAiAssistant/voice/getAudioById?Authentication=${Authentication}&id=${res.resultValue.id}&sign=${voiceSign}&timestamp=${timestamp}`
								sessionStorage.setItem("yyDatial", res.resultValue.sectionMessage)
								this.audio_speaker_content = JSON.parse(res.resultValue.sectionMessage)

								this.audio_speaker_content.forEach((item) => {
									if (!this.nameColor[item.speakerName]) {
										this.nameColor[item.speakerName] = this.colorList[Object.keys(this.nameColor).length];
									}
									if (item.content) {
										item.content.forEach((i) => {
											if (i.subIndex == -1) {
												i.word = i.word + "\n"
											}
											this.changearr.push(i)
										})
									}
								})
								console.log(this.changearr)
							}
						} else {
							mui.toast(res.resultValue, {
								duration: 'long',
								type: 'div'
							})
						}
					} else {
						mui.toast('完整性校验失败', {
							duration: 'long',
							type: 'div'
						})
					}
				},
				error: (e) => {
					this.initLoading = false
					mui.toast('请稍后再试', {
						duration: 1000,
						type: 'div'
					})
				},
			});
		},
		// 修改接口
		getreviseVoice(id, messageTitle, timestamp,num) {
			userId = sessionStorage.getItem("userId");
			if (sessionStorage.getItem("iscp_port")) {
				iscp_port = sessionStorage.getItem("iscp_port");
			} else {
				iscp_port = ""
			}
			let data = {
				"id": id, //主键id
				"messageTitle": messageTitle, //笔记标题
				"sectionMessage": JSON.stringify(this.audio_speaker_content), //笔记内容
				"userId": userId,
				"sceneNo": 106,
				"timestamp": timestamp,
			};
			let AuthenticationSession = sessionStorage.getItem("Authentication");
			data = JSON.stringify(data)
			let sign = sm3(data);
			$.ajax({
				url: localUrlLink + iscp_port + "/tjAiAssistant/voice/updateVoiceNotes",
				type: "post",
				async: false, //是否同步，false表示同步请求
				dataType: "json",
				data: data,
				headers: {
					"Content-Type": "application/json;charset=UTF-8",
					Authentication: AuthenticationSession,
					sign: sign
				},
				success: (res, txt, xhr) => {
					$(".curtain").css("display", "none");
					if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
						let Authentication = xhr.getResponseHeader("Authentication")
						if (res.code == 200) {
							if (Authentication) {
								sessionStorage.setItem("Authentication", Authentication);
								if(num == 1) return
								this.scjy()
							}
						} else {
							mui.toast(res.resultValue, {
								duration: 'long',
								type: 'div'
							})
						}
					} else {
						mui.toast('完整性校验失败', {
							duration: 'long',
							type: 'div'
						})
					}
				},
				error: (e) => {
					$(".curtain").css("display", "none");
					mui.toast('请稍后再试', {
						duration: 1000,
						type: 'div'
					})
				},
			});
		},

		complete(num) {
			if (!this.titleText && this.titleText.split(" ").join("").length == 0) {
				mui.toast('标题不能为空', {
					duration: 1000,
					type: 'div'
				})
				return
			} else {
				$(".curtain").css("display", "block")
				// if (this.VoiceFlag == false) { //修改
				let data = {
					"id": this.VoiceItemID, //主键id
					"messageTitle": this.titleText, //笔记标题
					"timestamp": new Date().getTime() + ""
				};
				this.getreviseVoice(data.id, data.messageTitle, data.timestamp,num)
			}
		},
		site(num) {
			var datas = JSON.parse(JSON.stringify(this.audio_speaker_content))
			var content = ''
			if (this.titleText == '' || this.titleText.split(" ").join("").length == 0) {
				mui.toast('标题不能为空', {
					duration: 1000,
					type: 'div'
				})
				return
			} else {
				datas.forEach((item, index) => {
					if (index == 0) {
						item.speakerName += "\n"
					} else {
						item.speakerName = "\n" + item.speakerName + "\n"
					}
					item.content.forEach((i) => {
						if (i.subIndex == -1) {
							i.word = "\n" + i.word
						}
						item.speakerName += i.word
					})
					content += item.speakerName
				})
			}
			this.content = content
			this.copy(0, 'tag-read')
		},
		copy(type, className) {
			let content = (type == 1 ? this.abstractContent : this.content)
			if (content == '' || content.split(" ").join("").length == 0) {
				mui.toast('内容不能为空', {
					duration: 'long',
					type: 'div'
				})
				return
			}
			if (!this.titleText || this.titleText.split(" ").join("").length == 0) {
				mui.toast('标题不能为空', {
					duration: 'long',
					type: 'div'
				})
				return
			}
			let text1 = content;
			var clipboard = new Clipboard('.' + className, {
				// 通过target指定要复印的节点
				text: function () {
					return text1
				}
			});
			console.log(5)
			clipboard.on('success', (e) => {
				mui.toast('复制成功', {
					duration: 'long',
					type: 'div'
				})
			});
			clipboard.on('error', (e) => {
				mui.toast('复制失败', {
					duration: 'long',
					type: 'div'
				})
			});
		},


	}
});